<template>
  <div>
    <table border="1px" width="600px">
      <tr><th>编号</th><th>姓名</th><th>年龄</th><th>性别</th><th>电话</th><th>地址</th></tr>
      <tr v-for="stu in students">
        <td>{{stu.id}}</td>
        <td>{{stu.name}}</td>
        <td>{{stu.age}}</td>
        <td>{{stu.gender}}</td>
        <td>{{stu.cellphone}}</td>
        <td>{{stu.address}}</td>
      </tr>
    </table>
  </div>
</template>

<script>
import axios from "axios";

export default {
  name: "StudentView",
  data(){
    return {
      students: []
    }
  },
  methods:{
    loadStudents(){
      //通过axios调用后台数据
      axios.get('http://localhost:8080/findStudents')
      .then(result =>{
        console.log(result.data)
        if (result.data.code === 200){
          this.students = result.data.data;
        }
      })
    }
  },
  mounted() {
    this.loadStudents();
  }
}
</script>

<style scoped>

</style>